#pragma once

#include <linux/types.h>

typedef struct qspinlock
{
    union
    {
        atomic_t val;

        /*
         * By using the whole 2nd least significant byte for the
         * pending bit, we can allow better optimization of the lock
         * acquisition for the pending bit holder.
         */
#ifdef __LITTLE_ENDIAN
        struct
        {
            u8 locked;
            u8 pending;
        };
        struct
        {
            u16 locked_pending;
            u16 tail;
        };
#else
        struct
        {
            u16 tail;
            u16 locked_pending;
        };
        struct
        {
            u8 reserved[2];
            u8 pending;
            u8 locked;
        };
#endif
    };
} arch_spinlock_t;
